#include "SplineBase.h"
#include <stdexcept>


//-------------------------------------

SplineBase::SplineBase() :
    xVec( 0 ),
    yVec( 0 ),
    N( 0 ),
    a( 0 )
{
    Clear();
}

//-------------------------------------

void SplineBase::Clear()
{
    new_xVec.clear();
    new_yVec.clear();
}

//-------------------------------------

void SplineBase::SetData( QVector< double > * x, QVector< double > * y )
{
    if( x == 0 && y == 0 )
        throw std::invalid_argument( "LeSl: Input Vectors are NULL" );

    if( x->count() == 0 && y->count() == 0 )
        throw std::invalid_argument( "LeSl: Input Vectors are empty" );

    if( x->count() != y->count() )
        throw std::invalid_argument( "LeSl: Input Vectors are not equal" );

    xVec = x;
    yVec = y;
}

//-------------------------------------

void SplineBase::GetData( QVector< double > * newX,  QVector< double > * newY )
{
    for( int j=0; j < new_xVec.count(); j++ )
    {
        newX->append( new_xVec.at( j ) );
        newY->append( new_yVec.at( j ) );
    }
    if( xVec->count() )
    {
        newX->append( xVec->at( xVec->count()-1 ) );
        newY->append( yVec->at( yVec->count()-1 ) );
    }
}

//-------------------------------------
